package sample.cluster.sample;

import akka.actor.ActorRef;
import akka.actor.ActorSystem;
import akka.actor.Props;
import com.typesafe.config.Config;
import com.typesafe.config.ConfigFactory;

/**
 * @author liuyi
 * @date 2017/03/08 13:53
 */
public class SampleClusterNode1 {
    public static void main(String[] args) throws InterruptedException {
        Config config = ConfigFactory.parseString(
                "akka.remote.netty.tcp.port=" + "2551").withFallback(
                ConfigFactory.load());


        // Create an Akka system
        ActorSystem system = ActorSystem.create("ClusterSystem", config);

        // Create an actor that handles cluster domain events
        ActorRef ref = system.actorOf(Props.create(SampleClusterListener.class), "clusterListener");
//        ActorRef ref = system.actorOf(Props.create(SampleClusterListener.class));
        System.out.println(ref.path());
        ActorRef exampleRef = system.actorOf(Props.create(ExampleActor.class), "exampleActor");

        for(int i=0;;i++){
            Thread.sleep(3000);
            exampleRef.tell("111", ActorRef.noSender());
        }

//        Cluster cluster = Cluster.get(system);
//        Cluster.get(system).down();
//        cluster.shutdown();
//        cluster.leave(cluster.selfAddress());
//        cluster.subscribe(sampleActor,);
//        cluster.system().actorOf()
    }
}
